﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using RenAi.Medical.Model;

namespace RenAi.Medical.DAL
{
    public class DocDAL
    {
        /// <summary>
        /// 获取医生信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetDocAll()
        {
            string sql = "select Doctor.Doctor_Id,Doctor.Doctor_Name,Doctor.Doctor_Img,HBKeShi.HBKeShi_Name,Doctor.Experience,Doctor.Adept,Doctor.Num ,Doctor.IFZhuanJia  from  Doctor join  HBKeShi  on Doctor.HBKeShi_Id=HBKeShi.HBKeShi_Id ";
            return DBhelper.GetTable(sql);
        }

        /// <summary>
        /// 根据编号删除医生信息
        /// </summary>
        /// <param name="Doctor_Id"></param>
        /// <returns></returns>
        //public int DelDocByID(string Doctor_Id)
        //{
        //    string sql = string.Format("delect from Doctor where Doctor_Id='{0}'", Doctor_Id);
        //    return DBhelper.NonQuery(sql);
        //}
        public int DelDoc(string Doctor_Id)
        {
            //string sql = string.Format("delete from Doctor where Doctor_Id='{0}'",Doctor_Id);
            //return DBhelper.NonQuery(sql);

            int i = DBhelper.NonQuery(string.Format("delete from Doctor where Doctor_Id='{0}'", Doctor_Id));
            return i;
        }

        /// <summary>
        /// 根据医生编号，获取要修费的医生信息
        /// </summary>
        /// <param name="Doctor_Id"></param>
        /// <returns></returns>
        public DataTable GetDocByID(string docid)
        {
            string sql = string.Format("select Doctor_Name,Doctor_Img, IFZhuanJia,HBKeShi_Id,Experience,Adept,Num from Doctor where Doctor_Id='{0}'", docid);
            return DBhelper.GetTable(sql);
        }

        /// <summary>
        /// 根据医生编号，修改医生信息
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public int UpDocByID(Doctor d)
        {
            string sql = string.Format("update  Doctor set Doctor_Name='{0}',Doctor_Img='{1}',IFZhuanJia='{2}',HBKeShi_Id='{3}',Experience='{4}',Adept='{5}',Num='{6}' where Doctor_Id='{7}' ", d.Doctor_Name, d.Doctor_Img, d.IFZhuanJia, d.HBKeShi_Id, d.Experience, d.Adept, d.Num, d.Doctor_Id);
            return DBhelper.NonQuery(sql);
        }


        /// <summary>
        /// 添加医生信息
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public int AddDoctor(Doctor d)
        {
            string sql = string.Format("insert into Doctor values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", d.Doctor_Name, d.IFZhuanJia, d.HBKeShi_Id, d.Doctor_Img, d.Experience, d.Adept, d.Num);
            return DBhelper.NonQuery(sql);
        }
    
    }
}
